package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.common.core.domain.entity.DockingErr;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IDockingErrService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 对接错误Controller
 * 
 * @author ess
 * @date 2021-10-18
 */
@RestController
@RequestMapping("/system/dockingErr")
public class DockingErrController extends BaseController
{
    @Autowired
    private IDockingErrService dockingErrService;

    /**
     * 查询对接错误列表
     */
    @PreAuthorize("@ss.hasPermi('system:dockingErr:list')")
    @GetMapping("/list")
    public TableDataInfo list(DockingErr dockingErr)
    {
        startPage();
        List<DockingErr> list = dockingErrService.selectDockingErrList(dockingErr);
        return getDataTable(list);
    }

    /**
     * 导出对接错误列表
     */
    @PreAuthorize("@ss.hasPermi('system:dockingErr:export')")
    @Log(title = "对接错误", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DockingErr dockingErr)
    {
        List<DockingErr> list = dockingErrService.selectDockingErrList(dockingErr);
        ExcelUtil<DockingErr> util = new ExcelUtil<DockingErr>(DockingErr.class);
        return util.exportExcel(list, "对接错误数据");
    }

    /**
     * 获取对接错误详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dockingErr:query')")
    @GetMapping(value = "/{dockErrId}")
    public AjaxResult getInfo(@PathVariable("dockErrId") String dockErrId)
    {
        return AjaxResult.success(dockingErrService.selectDockingErrByDockErrId(dockErrId));
    }

    /**
     * 新增对接错误
     */
    @PreAuthorize("@ss.hasPermi('system:dockingErr:add')")
    @Log(title = "对接错误", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DockingErr dockingErr)
    {
        return toAjax(dockingErrService.insertDockingErr(dockingErr));
    }

    /**
     * 修改对接错误
     */
    @PreAuthorize("@ss.hasPermi('system:dockingErr:edit')")
    @Log(title = "对接错误", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DockingErr dockingErr)
    {
        return toAjax(dockingErrService.updateDockingErr(dockingErr));
    }

    /**
     * 删除对接错误
     */
    @PreAuthorize("@ss.hasPermi('system:err:remove')")
    @Log(title = "对接错误", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dockErrIds}")
    public AjaxResult remove(@PathVariable String[] dockErrIds)
    {
        return toAjax(dockingErrService.deleteDockingErrByDockErrIds(dockErrIds));
    }
}
